import http from "../request";
const apibase = "/api/Common";
import qs from "qs";

//资产类型：根据关键字查询资产类别，
var GetAssetsTypeList = function (data) {
  const datas = qs.stringify(data);
  return new Promise((resolve, reject) => {
    http
      .post(apibase + `/GetAssetsTypeList?${datas}`)
      .then((res) => {
        resolve(res);
      })
      .catch((error) => {
        reject(error);
      });
  });
};
//资产类型属性：根据资产类型标识查询关联属性信息
var GetAssetsTypeAttributeList = function (data) {
  const datas = qs.stringify(data);
  return new Promise((resolve, reject) => {
    http
      .post(apibase + `/GetAssetsTypeAttributeList?${datas}`)
      .then((res) => {
        resolve(res);
      })
      .catch((error) => {
        reject(error);
      });
  });
};
//资产类型属性的类型
var GetDataTypeList = function (data) {
  return new Promise((resolve, reject) => {
    http
      .post(apibase + `/GetDataTypeList`, data)
      .then((res) => {
        resolve(res);
      })
      .catch((error) => {
        reject(error);
      });
  });
};
//查询工作项目信息
var GetJobItemList = function (data) {
  const datas = qs.stringify(data);
  return new Promise((resolve, reject) => {
    http
      .post(apibase + `/GetJobItemList?${datas}`)
      .then((res) => {
        resolve(res);
      })
      .catch((error) => {
        reject(error);
      });
  });
};
//上传文件
var CommonUploadFile = function (data) {
  return new Promise((resolve, reject) => {
    http
      .Filepost(apibase + `/UploadFile`, data)
      .then((res) => {
       
        resolve(res);
      })
      .catch((error) => {
        reject(error);
      });
  });
};

//获取报表目录
var getReports = function (data) {
  return new Promise((resolve, reject) => {
    http
      .get(apibase + `/GetReports`)
      .then((res) => {
       
        resolve(res);
      })
      .catch((error) => {
        reject(error);
      });
  });
};

//附件下载
var downloadEnclosureHis = function (data) {
  return new Promise((resolve, reject) => {
    http
      .post(apibase + `/downloadEnclosureHis`, data)
      .then((res) => {
        
        resolve(res);
      })
      .catch((error) => {
        reject(error);
      });
  });
};
//附件删除
var delEnclosureByRelationTableId = function (data) {
  return new Promise((resolve, reject) => {
    http
      .post(apibase + `/DelEnclosureByRelationTableId`, data)
      .then((res) => {
       
        resolve(res);
      })
      .catch((error) => {
        reject(error);
      });
  });
};

export {
  GetAssetsTypeList,
  GetAssetsTypeAttributeList,
  GetDataTypeList,
  GetJobItemList,
  CommonUploadFile,
  getReports,
  downloadEnclosureHis,
  delEnclosureByRelationTableId
};
